package com.litorg.demo.db.controller;

import com.alibaba.fastjson.JSONObject;
import com.litorg.demo.db.producer.MsgProducer;
import com.litorg.demo.db.vo.PrimaryConnectionDrawing;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Despriction:
 * @Author: wangcheng
 * @Date: 2022/3/21 19:55
 */
@RestController
@RequestMapping("test-mq")
public class TestMqController {

    private static final Logger log = LoggerFactory.getLogger(TestMqController.class);

    @Autowired
    private MsgProducer msgProducer;

    @GetMapping("send")
    public PrimaryConnectionDrawing send(@RequestParam("type") String type) {
        PrimaryConnectionDrawing ddd = new PrimaryConnectionDrawing();
        ddd.setType(type);
        // ddd.setId(1L);
        // ddd.setData(JSONObject.parseObject("{\"key2\": \"value2222\", \"key3\": \"value3\"}"));
        msgProducer.send("hot_send_fanout_exchange", "", ddd);
        return ddd;
    }

}
